package com.it.schoolhomeos.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDate;

/**
 * 考勤统计数据传输对象
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AttendanceStatDTO {
    
    /**
     * 日期
     */
    private LocalDate date;
    
    /**
     * 出勤人数
     */
    private int presentCount;
    
    /**
     * 缺勤人数
     */
    private int absentCount;
    
    /**
     * 请假人数
     */
    private int leaveCount;
    
    /**
     * 总人数
     */
    private int totalCount;
    
    /**
     * 出勤率
     */
    private double presentRate;
    
    /**
     * 缺勤率
     */
    private double absentRate;
    
    /**
     * 请假率
     */
    private double leaveRate;
    
    /**
     * 计算各项比率
     */
    public void calculateRates() {
        if (totalCount > 0) {
            this.presentRate = Math.round((double) presentCount / totalCount * 10000) / 100.0;
            this.absentRate = Math.round((double) absentCount / totalCount * 10000) / 100.0;
            this.leaveRate = Math.round((double) leaveCount / totalCount * 10000) / 100.0;
        } else {
            this.presentRate = 0;
            this.absentRate = 0;
            this.leaveRate = 0;
        }
    }
} 